package com.qyer.commons.mc.reloader;

import java.lang.reflect.Method;

/**
 * User: Z J Wu Date: 2016/03/07 Time: 18:04 Package: com.qyer.commons.mc.reloader
 */
public class DirectInvocationReloader<T> extends Reloader<T> {

  private Object invocationTarget;

  public DirectInvocationReloader(String reloadResource, Object invocationTarget) {
    super(reloadResource);
    this.invocationTarget = invocationTarget;
  }

  @Override public T _reload() throws Exception {
    Class clz = invocationTarget.getClass();
    Method method = clz.getMethod(reloadResource);
    return (T) method.invoke(invocationTarget);
  }
}
